package com.exam.mapper;

import com.exam.entity.Admin;
import com.exam.entity.Student;
import com.exam.entity.Teacher;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface LoginMapper {

    @Select("select adminId,adminName,sex,tel,email,cardId,role from admin where adminId = #{adminId} and pwd = #{pwd}")
    public Admin adminLogin(Admin admin);

    @Select("select teacherId,teacherName,institute,sex,tel,email,cardId," +
            "type,role from teacher where teacherId = #{teacherId} and pwd = #{pwd}")
    public Teacher teacherLogin(Teacher teacher);

    @Select("select studentId,studentName,grade,major,clazz,institute,tel," +
            "email,cardId,sex,role from student where studentId = #{studentId} and pwd = #{pwd}")
    public Student studentLogin(Student student);

    @Options(useGeneratedKeys = true, keyProperty = "studentId", keyColumn = "studentId")
    @Insert("insert into student(studentId,pwd) " +
            "values(#{studentId},#{pwd})")
    public int studentRegister(Student student);
}
